package com.auxgroup.hr.front.service.personnal.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import com.auxgroup.hr.front.dao.domain.PsCEducatTbl;
import com.auxgroup.hr.front.dao.domain.PsCPersonalInfoClass;
import com.auxgroup.hr.front.dao.repository.PsCEducatTblRepository;
import com.auxgroup.hr.front.service.personnal.EducatTblService;

/** 
 * @author wangchangyun
 * @version 创建时间：180523 
 * 以前工作经历表service
 */
@Service("educatTblService")
public class EducatTblServiceImpl implements EducatTblService {
	private static final Logger logger = LoggerFactory.getLogger(EducatTblServiceImpl.class);
	
	@Autowired
	private PsCEducatTblRepository PsCEducatTblRepository;


	@Override
	public PsCEducatTbl getEducatTbl(PsCPersonalInfoClass personalInfo) {
		return PsCEducatTblRepository.findOne(personalInfo);
	}


	@Override
	public PsCEducatTbl save(PsCEducatTbl EducatTbl) {
		return PsCEducatTblRepository.save(EducatTbl);
	}


	@Override
	public Boolean delete(PsCPersonalInfoClass personalInfo) {
		try {
			PsCEducatTblRepository.delete(personalInfo);
		} catch (Exception e) {
			logger.error("delete EducatTbl error: personalInfo={}",personalInfo,e);
			return false;
		}
		return true;
	}
	
	
	@Override
	public List<PsCEducatTbl> getAll(String emplid) {
		PsCEducatTbl EducatTbl = new PsCEducatTbl();
		EducatTbl.setEmplid(emplid);
		return PsCEducatTblRepository.findAll(Example.of(EducatTbl),new Sort(Sort.Direction.DESC,"startDt"));
	}


	
	
	
}
